Skip to content

Smooth transaction volume chart clean#105

Merged
Camillebzd merged 4 commits into
mainfrom
smooth-transaction-volume-chart-clean
Jun 9, 2026
Merged

Smooth transaction volume chart clean#105
Camillebzd merged 4 commits into
mainfrom
smooth-transaction-volume-chart-clean

Conversation

@Camillebzd

Copy link
Copy Markdown
Contributor

No description provided.

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
monode Ready Ready Preview, Comment Jun 9, 2026 9:20pm

Request Review

@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a smooth sliding animation to the TPS chart by introducing useSlidingNow (a requestAnimationFrame-driven clock), drawHistory (progressive segment interpolation), and buildTicks (frame-anchored x-axis ticks). The lockfile is also cleaned up by removing duplicate entries, and pnpm-workspace.yaml gains explicit allowBuilds entries for sharp and unrs-resolver.

  • drawHistory replaces the most recent history point with a linearly-interpolated "head" that travels from the previous point to the newest one over one inter-arrival interval, making the chart edge slide smoothly rather than snapping on each data arrival.
  • buildTicks generates explicit ticks anchored at now (the right edge) and stepping backward, preventing recharts from auto-placing duplicate "now" labels.
  • Lockfile / workspace changes remove accidentally duplicated package entries and add standard native-binary allowBuilds allowlist entries.

Confidence Score: 5/5

Safe to merge — the animation logic is well-contained and correctness degrades gracefully under unexpected conditions.

The new animation helpers are isolated to the chart component, recharts explicit domain and ticks props prevent stale axis state, and all edge cases are handled. The one notable concern is that the animation progress formula uses the server-embedded timestamp rather than client receive time, which could stall animation under clock skew, but the fallback behavior is a static chart rather than a crash or data corruption.

frontend/components/network-activity-tracker/tps-chart.tsx — specifically the progress formula in drawHistory if TPS timestamps are server-originated.

Important Files Changed

Filename Overview
frontend/components/network-activity-tracker/tps-chart.tsx Adds rAF-driven sliding clock, progressive segment interpolation, and explicit tick generation for smooth chart animation; animation progress is tied to the client clock vs. server timestamps, which can cause skipped or stalled animation on clock skew.
frontend/pnpm-lock.yaml Removes accidentally duplicated package and snapshot entries; no version or integrity hash changes.
frontend/pnpm-workspace.yaml Adds allowBuilds entries for sharp and unrs-resolver to permit their native postinstall scripts.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["useSlidingNow (rAF setState now)"] -->|now every frame| B[TpsChart render]
    C["useTps history"] --> B
    B --> D["drawHistory history now"]
    D --> E{history.length < 2?}
    E -- yes --> F[return history unchanged]
    E -- no --> G["duration = target.ts - from.ts"]
    G --> H{duration <= 0?}
    H -- yes --> F
    H -- no --> I["progress = clamp 0 to 1"]
    I --> J["head = lerp from to target at progress"]
    J --> K["chartData = history slice plus head"]
    B --> L["buildTicks windowStart now"]
    L --> M["step = first TICK_STEPS >= span/6"]
    M --> N["ticks anchored at now stepping back"]
    K --> O["AreaChart domain windowStart to now"]
    N --> O
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
frontend/components/network-activity-tracker/tps-chart.tsx:68
**Animation progress anchored to server timestamp, not client receive-time**

`progress` is computed as `(now - target.timestamp) / duration`, where `target.timestamp` is the timestamp embedded in the TPS data point. If those timestamps originate from the server clock, any client–server skew shifts the entire animation window: a client clock that lags the server will keep `progress` at 0 (clamped) until its clock catches up to `target.timestamp`, freezing the head at `from` and silently dropping the newest segment from the chart. The safe fix is to record the client-side receipt time and drive progress from that instead — e.g. store `receivedAt = Date.now()` alongside each incoming point and use `(now - receivedAt) / duration`.

Reviews (4): Last reviewed commit: "fix the x absis to have only 1 now" | Re-trigger Greptile

Comment thread frontend/components/network-activity-tracker/tps-chart.tsx
Comment thread frontend/components/network-activity-tracker/tps-chart.tsx
Camillebzd and others added 4 commits June 9, 2026 22:19
Switch the X axis to a continuous time scale whose right edge eases
toward the newest point's timestamp each animation frame. A freshly
appended point sits just past the edge (clipped by allowDataOverflow)
and is revealed sliding in from the right instead of snapping into a
discrete category slot; the animation halts once the edge catches up, so
the chart is still between points. isAnimationActive stays disabled to
avoid Recharts re-animation loops on every TPS event.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Camillebzd Camillebzd force-pushed the smooth-transaction-volume-chart-clean branch from 061abaf to 1f55e3a Compare June 9, 2026 21:20
@Camillebzd Camillebzd merged commit e6889b6 into main Jun 9, 2026
7 checks passed
@Camillebzd Camillebzd deleted the smooth-transaction-volume-chart-clean branch June 9, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants